package com.coment.po;

import com.coment.dto.ApiNotify;
import com.coment.dto.LiveData;
import lombok.*;
import org.springframework.data.annotation.Id;

@Setter
@Getter
@NoArgsConstructor
@ToString(of = {"id", "apiType", "anchorOpenId", "nickName", "liveStatus", "roundId"})
@EqualsAndHashCode(of = {"apiType", "anchorOpenId"}, callSuper = false)
public class AnchorInfo extends BasePO {
    @Id
    private Integer id;

    /// 渠道类型
    private String apiType;

    /// openId
    private String anchorOpenId;

    /// 房间号
    private String roomId;

    /// 头像
    private String avatarUrl;

    /// 昵称
    private String nickName;

    /// 直播状态
    private Integer liveStatus;

    /// 轮次
    private int roundId;


    /// 最新的直播时间
    private Long liveTime;

    public AnchorInfo(LiveData.DyPayload.AnchorInfo anchorInfo) {
        this.apiType = LiveData.ApiType.douyin.getValue();
        this.anchorOpenId = anchorInfo.getAnchorOpenId();
        this.roomId = anchorInfo.getRoomId();
        this.avatarUrl = anchorInfo.getAvatarUrl();
        this.nickName = anchorInfo.getNickName();
        this.roundId = anchorInfo.getRoundId();
        this.liveStatus = 1;
        this.id = this.hashCode();
    }


    public AnchorInfo(ApiNotify apiNotify) {
        this.apiType = apiNotify.getApiType().getValue();
        this.anchorOpenId = apiNotify.getAnchorInfoId().toString();
        this.roomId = apiNotify.getRoomId();
//      this.avatarUrl = apiNotify.ge
//      this.nickName = apiNotify.getNickName();
//      this.roundId = apiNotify.getRoundId();
        this.liveStatus = 1;
        this.id = this.hashCode();
    }

    public AnchorInfo(String apiType, String roomId) {
        this.apiType = apiType;
        this.roomId = roomId;
        this.anchorOpenId = roomId;
        this.id = this.hashCode();
    }

    public AnchorInfo(LiveData.KSPayload.KSPayloadData.Payload.UserInfo userInfo , String roomCode) {
        this.apiType = LiveData.ApiType.kuaiShou.getValue();
        this.anchorOpenId = userInfo.getUserId();
        this.avatarUrl = userInfo.getHeadUrl();
        this.roomId = roomCode;
        this.liveTime = System.currentTimeMillis();
        this.id = this.hashCode();
    }
}
